package fr.janalyse

import scala.collection.generic.CanBuildFrom
import scala.language.implicitConversions

package object series {

  type CSV2Series = fr.janalyse.series.csv.CSV2Series
  val CSV2Series = fr.janalyse.series.csv.CSV2Series

  type CSVFormat = fr.janalyse.series.csv.CSVFormat
  val CSVFormat = fr.janalyse.series.csv.CSVFormat

  final class RaisedForSeries[N <% Number, C <: Cell](n: N) {
    def *(x: Series[C]): Series[CalcCell] = x * n
    def +(x: Series[C]): Series[CalcCell] = x + n
    def /(x: Series[C]): Series[CalcCell] = x / n
    def -(x: Series[C]): Series[CalcCell] = x - n
  }
  implicit def raiseToSeries[N <% Number, C <: Cell](n: N): RaisedForSeries[N, C] = new RaisedForSeries[N, C](n)

  
  /*
  def align[C <: Cell, A <: Series[C], I[A] <: Iterable[A]] (list: I[A], timeNorm: Long => Long = x => x)
    (implicit bf: CanBuildFrom[I[A], A, I[A]], cellBuilder: CellBuilder[C]): I[A] = {
    // We'll only take common normalized time for all given series
    val times2alignwith =
      list
        .map(_.map(c => timeNorm(c.time)))
        .reduce(_ intersect _)
        .toSet

    val baselist =
      list
        .map(_.take(times2alignwith.head, times2alignwith.last))
        .map(_.sample(timeNorm))
        .map(_.filter(c => times2alignwith contains c.time))

    var builder = bf.apply()
    var prev: Option[A] = None
    for (series <- list) {
    //for (series <- baselist) {  // TODO TO FINISH
      val alignedSeries = series
      builder += alignedSeries
    }
    builder.result
  }
*/
  /*  */
}
